package cn.dyw.cloudmusic.http.model;

import cn.dyw.cloudmusic.config.ParamsConfig;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;

@Data
public class CommentParams implements Params {

    @JSONField(ordinal = 1)
    private String rid;

    @JSONField(ordinal = 2)
    private int offset;

    @JSONField(ordinal = 3)
    private boolean total;

    @JSONField(ordinal = 4)
    private int limit;

    @JSONField(ordinal = 5, name = "csrf_token")
    private String csrfToken;

    @JSONField(serialize=false)
    private String id;

    @JSONField(serialize = false)
    private String url;

    public CommentParams(String rid) {
        this.rid = "R_SO_4_" + rid;
        this.id = rid;
        this.offset = 0;
        this.total = true;
        this.limit = 100;
        this.csrfToken = "";
        url = ParamsConfig.commentUrl.replace("{}", id);
    }

    public void next() {
        this.offset += limit;
        this.total = false;
    }

    @Override
    public String songId() {
        return id;
    }

    @Override
    public String requestUrl() {
        return url;
    }
}
